﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.PeerResolvers;
using System.ServiceModel;

namespace ResolverService
{
    public class ServiceRun
    {
        public static void Main()
        {
            // Create a new resolver service
            CustomPeerResolverService crs = new CustomPeerResolverService();
            crs.ControlShape = false;

            
            // Create a new service host
            ServiceHost customResolver = new ServiceHost(crs);

            // Open the resolver service 
            crs.Open();
            customResolver.Open();
            customResolver.UnknownMessageReceived += new EventHandler<UnknownMessageReceivedEventArgs>(PerceiveContact);
            Console.WriteLine("Custom resolver service is started");
            Console.WriteLine("Press <ENTER> to terminate service");
            Console.ReadLine();
        }

        static void PerceiveContact(object sender, UnknownMessageReceivedEventArgs e)
        {
            Console.WriteLine(e.Message.Headers[3]);
        }
    }
}
